<template>
  <div>
    <Header></Header>
    <!-- 路由组件出口的地方 -->
    <router-view></router-view>
    <!-- 在登录和注册隐藏 -->
    <Footer v-show="$route.meta.show"></Footer>
  </div>
</template>

<script>
import {removeToken} from '@/utils/token'
import Header from './components/Header'
import Footer from './components/Footer'
export default {
  name: 'App',
  components: {
    Header,Footer
  },
  mounted() {
    //派发一个action 获取商品分类的三级列表数据
    //通知Vuex发送请求，获取数据，存储在仓库中
    this.$store.dispatch("home/categoryList");
    (async ()=>{
      try {
        await this.$store.dispatch('user/getUserInfo');
      } catch (error) {
        removeToken();
      }
    })()
  },
}
</script>




